package com.ts.enterprise.module.user.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ts.enterprise.common.service.CommonService;
import com.ts.enterprise.common.utils.RedisUtil;
import com.ts.enterprise.enums.EnableEnum;
import com.ts.enterprise.enums.RedisKeyEnum;
import com.ts.enterprise.module.user.entity.Dict;
import com.ts.enterprise.module.user.entity.Tag;
import com.ts.enterprise.module.user.mapper.DictMapper;
import com.ts.enterprise.module.user.mapper.TagMapper;
import com.ts.enterprise.module.user.vo.DictResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dean
 * @since 2021-10-18
 */
@Service
public class TagService extends ServiceImpl<TagMapper, Tag> {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private CommonService commonService;

    @Autowired
    private LoginService loginService;

    public List<Tag> listAll(Integer showType, Integer valueType) {
        LambdaQueryWrapper<Tag> eq = new LambdaQueryWrapper<Tag>()
                .eq(Tag::getActive, EnableEnum.enable.getCode())
                .eq(null!=showType, Tag::getShowType, showType)
                .eq(null!=valueType, Tag::getValueType, valueType)
                .orderByAsc(Tag::getShowType,Tag::getSort,Tag::getId);
        return super.list(eq);
    }

}
